﻿using System;
using System.Collections.Generic;

namespace com.foxmail.wyyuan1991.Assignment.Solver.Data
{
    /// <summary>
    /// 一条边约束 g(x)>=0
    /// </summary>
    public class SideConstraint
    {
        /// <summary>
        /// g(x)对弧流量x的偏导数
        /// </summary>
        private Dictionary<IArc, Func<IFlowPattern,double>> _Dic = new Dictionary<IArc, Func<IFlowPattern, double>>();
        public Func<IFlowPattern, double> this[IArc a]
        {
            get
            {
                if (_Dic.ContainsKey(a))
                {
                    return _Dic[a];
                }
                else
                {
                    return ((IFlowPattern fa) =>0);
                }
            }
            set
            {
                if (!_Dic.ContainsKey(a)) _Dic.Add(a, null);
                _Dic[a] = value;
            }
        }
        /// <summary>
        /// 边约束函数 g(x)
        /// </summary>
        public virtual Func<IFlowPattern, double> LMF { get; set; }
        public string Name { get; set; }
        public override string ToString()
        {
            return Name;
        }
    }
}
